package com.hackintosh.chat;

import java.util.ArrayList;
import java.util.List;

/**
 * @description：
 * @author：twislyn
 * @date：Created in 2021/06/03
 * @modified By：
 * @version: 1.0
 */
public class Sunco implements Medium {
    private List<Customer> members = new ArrayList<>();
    @Override
    public void register(Customer customer) {
        if(!members.contains(customer)){
            members.add(customer);
            customer.setMedium(this);
        }
    }

    @Override
    public void reply(String from, String sentence) {
        for (Customer customer : members) {
            String name = customer.getName();
            if(!name.equals(from)) {
                customer.receive(name, sentence);
            }
        }
    }
}
